<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/boot.js"></script>
</head>

<body>
    <div class="layui-fluid">
        <div class="flexrow">
            <div class="layui-panel list-container">
                <div class="list-search-container">
                    <button class="layui-btn layui-btn-sm" onclick="HandleAdd()"><i class="layui-icon layui-icon-add-1 layui-font-12"></i>新增版本</button>
                    <div class="list-search-item">
                        <span>版本名称：</span>
                        <input id="version_name" autocomplete="off" class="layui-input">
                    </div>
                    <button class="layui-btn layui-btn-sm" style="margin-left:5px" onclick="BindTableData()"><i class="layui-icon layui-icon-search layui-font-12"></i>搜索</button>
                </div>
                <table class="layui-table" lay-data="{id: 'datagrid'}" lay-filter="datagrid">
                    <thead>
                        <tr>
                            <th lay-data="{field:'version_name' ,align:'left',width:300}">版本名称</th>
                            <th lay-data="{field:'gmt_create' ,align:'center',width:200}">创建时间</th>
                            <th lay-data="{field:'version_number' ,align:'center',width:120}">版本号</th>
                            <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#version_status'}">版本状态</th>
                            <th lay-data="{field:'version_remark' ,align:'left'}">版本说明</th>
                            <th lay-data="{fixed: 'right', width:200, align:'center', toolbar: '#op'}">操作</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</body>
<script type="text/html" id="version_status">
    {{# if(d.version_status=='enable'){ }}
        <div style='color:green'>启用</div>
    {{# } else { }}
        <div style='color:red'>禁用</div>
     {{# } }}
</script>
<script type="text/html" id="op">
    <button class="layui-btn layui-btn-sm" lay-event="HandleEdit"><i class="layui-icon layui-icon-edit layui-font-12"></i>编辑</button>
    <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="HandleDelete"><i class="layui-icon layui-icon-delete layui-font-12"></i>删除</button>
</script>
<script>
    $(function() {
        BindTableData();
    })

    function BindTableData() {
        var param = {
            pguid: GetUrlParam("pguid"),
            version_name: $("#version_name").val(),
        }
        BindTable("datagrid", "workflow/desgin/progressversion/list", param);
    }


    function HandleAdd() {
        OpenDialog('新增版本', 'workflow/progressversion/progressversion_add.html?pguid='+GetUrlParam("pguid"), 800, 600, function() {
            BindTableData();
        })
    }

    function HandleEdit(RowData) {
        OpenDialog('修改版本', 'workflow/progressversion/progressversion_edit.html?rowguid=' + RowData.rowguid, 800, 600, function() {
            BindTableData();
        })
    }

    function HandleDelete(RowData) {
        OpenConfirm('确认删除？', function() {
            var param = {
                rowguid: RowData.rowguid
            }
            HttpPost(JSON.stringify(param), 'workflow/desgin/progressversion/delete', function(result) {
                if (result.code == 0) {
                    OpenSuccessMessage("删除成功")
                    BindTableData();
                } else {
                    OpenFail(result.msg);
                }
            })
        })
    }
</script>

</html>